from typing import Optional, List
from datetime import datetime
from pydantic import condecimal
from .base import BaseSchema
from pydantic import ConfigDict

class HotelOrderBase(BaseSchema):
    work_area_id: int
    package_order_id: Optional[int] = None
    package_order_title: Optional[str] = None
    customer_profile_id: Optional[int] = None
    
    # 酒店基本信息
    CityName: str
    HotelName: str
    RoomType: str
    RoomUnitPrice: condecimal(max_digits=18, decimal_places=2)
    BookRoomCount: int
    TotalPrice: condecimal(max_digits=18, decimal_places=2)
    CheckInTime: datetime
    StayDayCount: int
    ContactName: str
    ContactTelNo: str
    CreatorName: str
    CreatorUserName: str

class HotelOrderCreate(HotelOrderBase):
    pass

class HotelOrderUpdate(HotelOrderBase):
    CityName: Optional[str] = None
    HotelName: Optional[str] = None
    RoomType: Optional[str] = None
    RoomUnitPrice: Optional[condecimal(max_digits=18, decimal_places=2)] = None
    BookRoomCount: Optional[int] = None
    TotalPrice: Optional[condecimal(max_digits=18, decimal_places=2)] = None
    CheckInTime: Optional[datetime] = None
    StayDayCount: Optional[int] = None
    ContactName: Optional[str] = None
    ContactTelNo: Optional[str] = None

class HotelOrder(HotelOrderBase):
    ID: int
    CreateTime: datetime
    UpdateTime: Optional[datetime] = None

    model_config = ConfigDict(from_attributes=True)

class HotelOrderList(BaseSchema):
    items: List[HotelOrder]
    total: int

# 乘客相关
class HotelOrderPassengerBase(BaseSchema):
    hotel_order_id: int
    PassengerName: str
    PassengerType: str
    PassengerIDType: str
    PassengerIDNo: str
    PassengerTelNo: Optional[str] = None

class HotelOrderPassengerCreate(HotelOrderPassengerBase):
    pass

class HotelOrderPassengerUpdate(HotelOrderPassengerBase):
    pass

class HotelOrderPassenger(HotelOrderPassengerBase):
    ID: int
    CreateTime: datetime
    UpdateTime: Optional[datetime] = None

    model_config = ConfigDict(from_attributes=True) 